﻿using Amiable.SDK.Enum;
using Amiable.SDK.EventArgs;
using Amiable.SDK.Interface;
using System.Text;

namespace AmiDraw.Code
{
    public class CheckinEvent : IPluginEvent
    {
        public AmiableEventType EventType => AmiableEventType.Group;

        public void Process(AmiableEventArgs e)
        {
            var ee = e.AsMessageEventArgs();
            var msg = ee.RawMessage;
            if (msg == "抽卡3签到")
            {
                if (Util.UserDataUtil.CanCheckin(ee.UserId))
                {

                    var times = Util.UserDataUtil.AddLeftTime(ee.UserId, "default", 10);
                    var sb = new StringBuilder();
                    sb.AppendLine($"你签到成功了!");
                    sb.AppendLine($"> 赫尔给你增加了10次抽卡机会~");
                    sb.AppendLine($"> 剩余次数{times - 10} -> {times}");
                    ee.SendMessage(sb.ToString());
                    Util.UserDataUtil.SetCheckinTime(ee.UserId);
                }
                else
                {
                    var sb = new StringBuilder();
                    sb.AppendLine("你已经签过到了!!");
                    ee.SendMessage(sb.ToString());
                }
            }
        }
    }
}

